<template>
    <div id="promotion" class="min_width">
        <!--头部导航-->
        <Header :chooseIt="chooseIt"></Header>
        <!--头部导航结束-->
        <main class="mainShow">
            <!-- 左侧导航 -->
            <div class="main-left">
                <!-- 多级导航 -->
                <el-aside width="100%" style="color: #333">
                    <el-menu default-active="/promotionList" :router="true" :unique-opened='true'>

                        <el-submenu index="/promotionList" v-if="!is_join">
                            <template slot="title">促销管理</template>
                            <el-menu-item-group>
                                <el-menu-item
                                        index="/promotionList"
                                        :class="{'isActive': active == '/promotionList' }"
                                        @click="reload()"
                                >促销项目</el-menu-item>
                                <el-menu-item
                                        index="/promotionAdd"
                                        :class="{'isActive': active == '/promotionAdd'  }"
                                        @click="reload()"
                                >添加促销项目</el-menu-item>
                                <el-menu-item
                                        index="/promotionRecord"
                                        :class="{'isActive': active == '/promotionRecord' }"
                                        @click="reload()"
                                >促销金明细</el-menu-item>
                            </el-menu-item-group>
                        </el-submenu>
                        <!-- 维修员管理 -->
                        <el-submenu index="/onlineTemplate">
                            <template slot="title">模板管理</template>
                            <el-menu-item-group>
                                <el-menu-item
                                        index="/onlineTemplate"
                                        :class="{'isActive': active == '/onlineTemplate'}"
                                        @click="reload()"
                                >价格模板</el-menu-item>
                                <el-menu-item
                                        index="/userTemplate"
                                        :class="{'isActive': active == '/userTemplate'}"
                                        @click="reload()"
                                >用户自助充值模板</el-menu-item>
                                <el-menu-item
                                        index="/partnerTemplate"
                                        :class="{'isActive': active == '/partnerTemplate'}"
                                        @click="reload()"
                                >代客充值模板</el-menu-item>
                            </el-menu-item-group>
                        </el-submenu>
                    </el-menu>
                </el-aside>
            </div>
            <!-- 左侧导航结束  -->

            <!-- 右侧主内容区 -->
            <div class="main-right">
                <transition name="fade">
                    <router-view class="view" :key="activeDate"></router-view>
                </transition>
            </div>
            <!-- 右侧主内容区结束 -->
        </main>
    </div>
</template>

<script>
    import $ from "jquery";
    export default {
        name: "promotion",
        data: function() {
            return {
                activeDate: "", //刷新页面
                chooseIt: 12,
                active: "/promotionList",
                headerFixed: true,
                type: 0,
                is_join:false
            };
        },
        created: function() {
            this.active = this.$route.path;
            this.getPartner();
		},  
         // 提供可注入子组件属性
		provide () {
			return {
				reload: this.reload
			}
		},
		methods: {
			//当前选中状态 reload定义
			reload() {
				// $nextTick() 将回调延迟到下次 DOM 更新循环之后执行
				this.$nextTick(() => {
					this.activeDate = Number(Date.parse(new Date()));
				})
			},
            //获取合伙人信息
            getPartner(){
                var that = this;
                that.$post({
                    url:'Partner/Setup/get_partner',
                    data:{
                    },
                    success:function(data){
                        // that.userinfo = data.data;
                        if(data.data.superior_id != '0'){
                            that.is_join = true;
                        }
                    }

                })
            },
            //获取屏幕高度
            getHeight() {
                var newHeight = $(window).height() - 100;
                $(".mainShow").css("min-height", newHeight + "px");
            }
        },
        mounted() {
            this.getHeight();
        },
        watch: {
            $route: function(to, from) {
                let { type = 0 } = to.query;
                this.type = type;
                this.active = to.path;
            },
            deep: true
        }
    };
</script>

<style>
    body {
        margin: 0;
        padding: 0;
    }
</style>
